<?php

namespace App\ZL\CrawlerExpansion;

use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\WebDriverCapabilityType;

class SinglePageHandler
{
    static $driver=null;

    public static function getDriver()
    {
        if(self::$driver==null){
            self::$driver = self::createDriver();
        }
        return self::$driver;
    }

    public static function createDriver()
    {
        $host = '127.0.0.1:8910';
        $capabilities = array(
            WebDriverCapabilityType::BROWSER_NAME => 'phantomjs',
            'phantomjs.page.settings.userAgent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0',
        );
        return RemoteWebDriver::create($host, $capabilities, 5000);
    }
    
    public static function getPageInfo($url)
    {
        set_time_limit(0);
        $driver = self::getDriver();
//        $driver->get()
    }
}